package net.koodar.forge.business.category.model.dto;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Getter;
import lombok.Setter;
import net.koodar.forge.business.category.model.entity.Category;
import net.koodar.forge.mybatis.doman.page.AbstractPageQuery;

/**
 * @author liyc
 */
@Getter
@Setter
public class CategoryQueryDTO extends AbstractPageQuery<Category> {

    private Long parentId;

    private String name;

    @Override
    public QueryWrapper<Category> addQueryCondition() {
        QueryWrapper<Category> queryWrapper = Wrappers.query();
        queryWrapper.eq(parentId != null, "parent_id", parentId);
        queryWrapper.eq(StrUtil.isNotBlank(name), "name", name);
        return queryWrapper;
    }
}
